//
// Created by twlin on 2024/8/7.
//

#ifndef COMMUNICATION_CTCPSERVER_H
#define COMMUNICATION_CTCPSERVER_H

#include "csocket.h"
#include <list>
#include <mutex>


class CTcpServer
{
public:
    CTcpServer();
    ~CTcpServer();

    static CTcpServer *getInstance();
    static void deleteInstance();

    bool startEpoll();
    void stopEpoll();

private:
    int mz_ipv4_tcp_create_socket();
    int mz_process_data(int sockfd);

private:
    static CTcpServer *_pInstance;
    static std::mutex _mutex;

    socket_t _listenfd;
    std::list<socket_t> _sockets;
    bool _bRunning;
};


#endif //COMMUNICATION_CTCPSERVER_H
